{
 "cells": [
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "# ***Introduction to Radar Using Python and MATLAB***\n",
    "## Andy Harrison - Copyright (C) 2019 Artech House\n",
    "<br/>\n",
    "\n",
    "# Noise Figure\n",
    "***"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "For cascaded networks, the noise figure is the contribution from each stage in the receive chain as (Equation 5.2)\n",
    "\n",
    "$$\n",
    "F_{total} = F_1 + \\sum_{i=2}^{N}\\left(\\frac{F_i - 1}{\\prod_{j=1}^{i-1}G_j}\\right)\n",
    "$$\n",
    "***"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "Begin by setting the library path"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 1,
   "metadata": {},
   "outputs": [],
   "source": [
    "import lib_path"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "Set the gain (dB) and noise figure (dB) for each stage in the receiver chain"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 2,
   "metadata": {},
   "outputs": [],
   "source": [
    "gain_db = [20.0, -0.5, -6.0, -1.0, 30.0]\n",
    "\n",
    "noise_figure_db = [3.0, 0.5, 6.0, 1.0, 5.0]"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "Calculate the total noise figure (dB) using the `total_noise_figure` routine"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 3,
   "metadata": {},
   "outputs": [],
   "source": [
    "from Libs.receivers import noise_figure\n",
    "\n",
    "total_noise_figure = noise_figure.total_noise_figure(gain_db, noise_figure_db)"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "Display the total noise figure"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 4,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "3.3507\n"
     ]
    }
   ],
   "source": [
    "print('{:.4f}'.format(total_noise_figure))"
   ]
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.8.5"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 4
}
